package com.tuocent.dagv2.controller;

import com.tuocent.dagv2.common.AjaxResult;
import com.tuocent.dagv2.entity.Customer;
import com.tuocent.dagv2.service.ICustomerService;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * <p>
 * 客户信息 前端控制器
 * </p>
 *
 * @author Vincent
 * @since 2025-08-19
 */
@Controller
@RequestMapping("/caes")
public class CaesController {

    @Autowired
    private ICustomerService customerService;

    @RequestMapping("customerInfo")
    public String getCustomerInfo(Model model) {
        return "/caes/customerInfo";
    }

    @RequestMapping("getCustomerData")
    @ResponseBody
    public AjaxResult getCustomerData(@RequestBody Map<String, Object> param) {
        return customerService.getCustomerData(param);
    }

    @RequestMapping("setCustomerInfo")
    public String setCustomerInfo(Model model,
                                  @RequestParam("id") String id) {
        return customerService.setCustomerInfo(model, id);
    }

    @RequestMapping("saveCustomerInfo")
    @ResponseBody
    public AjaxResult saveCustomerInfo(HttpSession session,
                                       @RequestBody Customer data) {
        return customerService.saveCustomerInfo(session, data);
    }

    @RequestMapping("delCustomer")
    @ResponseBody
    public AjaxResult delCustomer(HttpSession session,
                                  @RequestBody Map<String, String> data) {
        return customerService.delCustomer(session, data);
    }
}
